#include <stdio.h>
#define LEN 20

void s_get(char *st, int n);
void reserve_ch(char st[], int n);

int main(int argc, char *argv[]) {
    int n;
    char str[LEN];

    printf("Input the length of str: ");
    while (scanf("%d", &n) == 1) {
        getchar(); // Consume newline after reading n
        s_get(str, n);
        
        reserve_ch(str, n);
        printf("End\n");
        puts(str);
        printf("Input the length of str: ");
    }
    return 0;
}

void s_get(char *st, int n) {
    int i = 0;

    if (fgets(st, n, stdin)) {
        while (st[i] != '\n' && st[i] != '\0')
            i++;
        if (st[i] == '\n')
            st[i] = '\0';
        else
            while (getchar() != '\n')
                continue;
    }
}

void reserve_ch(char st[], int n) {
    int i;
    char temp[LEN];
    for (i = 0; i < n-1; i++)
        temp[i] = st[i];
    st[n-1]='\0';
    for (i = 0; i < n-1; i++)
        st[i] = temp[n - i - 2];
}
